#ifndef _Mutation_BitFlip_H_
#define _Mutation_BitFlip_H_

#include "../../Elements/Chromosome.h"
#include "Mutation.h"

#include "../../Rng/GlobalRng.h"

using namespace std;

/********************************************************************
Headers
********************************************************************/
/*!
 * \brief
 * Implementation of bit-flip mutation (applicable binary-coded chromosomes).
 *  
 * \see
 * Mutation | Mutation_Gaussian
 */
class Mutation_BitFlip : public Mutation<bool> {
public:
	Mutation_BitFlip(double pMutation);

	virtual bool mutate(Chromosome<bool>& chromosome);

private:	
};

/********************************************************************
Implementation
********************************************************************/
Mutation_BitFlip::Mutation_BitFlip(double pMutation) : Mutation<bool>(pMutation)
{
}


bool Mutation_BitFlip::mutate(Chromosome<bool>& chromosome)
{
	//double randomNumber = Rng::uni();
	//if (randomNumber > this->pMutation) return false;

	for (unsigned int i=0; i<chromosome.size(); i++)
	{
		double randomNumber = Rng::uni();

		if (randomNumber <= pMutation) chromosome[i] = ~chromosome[i];
	}

	return true;
}

#endif
